/*     */ package com.qmsk.business.task.discussReply.controller;
/*     */ 
/*     */ import com.qmsk.business.task.discussReply.dao.DiscussReplyDao;
/*     */ import com.utils.basic.CDateTimeComm;
/*     */ import com.utils.basic.MapUtils;
/*     */ import com.utils.basic.ObjectComm;
/*     */ import com.utils.gson.in.GsonHeadOneRow;
/*     */ import com.utils.gson.in.ParserDataSetJson;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.util.Date;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.commons.lang.StringUtils;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"discussReply"})
/*     */ public class DiscussReplyController
/*     */ {
/*  34 */   private static final Logger logger = Logger.getLogger(DiscussReplyController.class);
/*     */ 
/*     */   @Autowired
/*     */   private DiscussReplyDao dao;
/*     */ 
/*     */   @Transactional(rollbackFor={Exception.class})
/*     */   @RequestMapping(value={"insert/insertInfo"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*     */     try
/*     */     {
/*  51 */       int nResult = 0;
/*  52 */       String sData = RequestUtils.getStringOfData(request);
/*  53 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/*  54 */       if ((p != null) && (p.isExistsInsertRows())) {
/*  55 */         GsonHeadOneRow g = (GsonHeadOneRow)p.getListInsertRows().get(0);
/*  56 */         Date now = new Date();
/*  57 */         g.autoAddHeadData("createdTime", now);
/*  58 */         nResult = this.dao.applyUpdates(p, "id");
/*  59 */         if (nResult > 0) {
/*  60 */           g = (GsonHeadOneRow)p.getListInsertRows().get(0);
/*  61 */           Long id = ObjectComm.objectToLong(g.getValueOfName("id"));
/*  62 */           String[] head = { "createdTime", "id" };
/*  63 */           Object[] data = { CDateTimeComm.dateToString(now, "yyyy-MM-dd HH:mm:ss"), id };
/*  64 */           DbConnection.commit();
/*  65 */           ResponseUtils.toGsonEbRst(head, data, response);
/*  66 */           return;
/*     */         }
/*  68 */         DbConnection.rollback();
/*     */       }
/*     */ 
/*  71 */       DbConnection.rollback();
/*     */ 
/*  73 */       ResponseUtils.setSqlResultResponse(nResult, 
/*  74 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/*  75 */         response);
/*     */     } catch (Exception e) {
/*  77 */       logger.error(e);
/*  78 */       DbConnection.rollback();
/*  79 */       ResponseUtils.setErrorMsgResponse(
/*  80 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/*  81 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/discussList/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOptShopId(HttpServletRequest request, HttpServletResponse response, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/* 128 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/* 130 */       Map params = new HashMap();
/* 131 */       String noteId = RequestUtils.getString(request, "noteId");
/* 132 */       String shopId = RequestUtils.getString(request, "shopId");
/* 133 */       if (StringUtils.isEmpty(noteId)) {
/* 134 */         noteId = "0";
/*     */       }
/* 136 */       MapUtils.addToMap(params, "noteId", noteId);
/* 137 */       MapUtils.addToMap(params, "shopId", shopId);
/* 138 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopId(params, nPageIdx, nPageSize);
/* 139 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/* 141 */       logger.error(e);
/* 142 */       ResponseUtils.setErrorMsgResponse(
/* 143 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/allReply"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getAllReply(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*     */     try {
/* 151 */       Map params = new HashMap();
/* 152 */       MapUtils.addToMap(params, "discussId", RequestUtils.getString(request, "id"));
/* 153 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopId(params);
/* 154 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/* 156 */       logger.error(e);
/* 157 */       ResponseUtils.setErrorMsgResponse(
/* 158 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional(rollbackFor={Exception.class})
/*     */   @RequestMapping(value={"del"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 177 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 179 */       String[] strParams = id.split(",");
/* 180 */       int nResult = this.dao.deleteParams(strParams);
/* 181 */       if (nResult > 0)
/* 182 */         DbConnection.commit();
/*     */       else {
/* 184 */         DbConnection.rollback();
/*     */       }
/* 186 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 187 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 188 */         response);
/*     */     } catch (Exception e) {
/* 190 */       DbConnection.rollback();
/* 191 */       logger.error(e);
/* 192 */       ResponseUtils.setErrorMsgResponse(
/* 193 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 194 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.task.discussReply.controller.DiscussReplyController
 * JD-Core Version:    0.5.3
 */